/*
 * Created with IDEA.
 * Description: A fully open-sourced high performance unibody close-loop driver for
 * Step-Motor, which was used in my DummyRobot project:
 * https://github.com/peng-zhihui/Dummy-Robot
 * Based on XDrive project: https://github.com/unlir/XDrive
 * @Author: Pengzhihui
 * @Date: ${DATE} ${TIME}
 *
 */

//
// Created by deng on 2022/12/25.
//

#ifndef MOTOR_S_ENCODER_BASE_H
#define MOTOR_S_ENCODER_BASE_H

#include <cstdint>


class EncoderBase
{
public:
    typedef struct
    {
        uint16_t rawAngle;          // raw data
        uint16_t rectifiedAngle;    // calibrated rawAngle data
        bool rectifyValid;
    } AngleData_t;
    AngleData_t angleData{0};


    /*
     * Resolution is (2^14 = 16384), each state will use an uint16 data
     * as map, thus total need 32K-flash for calibration.
    */
    const int32_t RESOLUTION = ((int32_t) ((0x00000001U) << 14));

    virtual bool Init() = 0;

    // Get current rawAngle
    virtual uint16_t UpdateAngle() = 0;

    virtual bool IsCalibrated() = 0;


private:

};

#endif //MOTOR_S_ENCODER_BASE_H
